<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>倒计时跳转页面</title>
</head>

<body>
    <button>离不开你</button>
    <span></span>
</body>

</html>
<script>
    window.addEventListener('DOMContentLoaded', function(e) {
        let span = window.document.querySelector('span');
        let button = window.document.querySelector('button');
        let prefix = "支付成功 "
        let suffix = " 秒中后跳转页面...";
        let count = 10;
        span.innerHTML = prefix + count-- + suffix;
        let timer = setInterval(() => {
            if (count == 0) {
                // window.location.href = "url"页面跳转 跳转后可以后退
                // window.location.assign("url") 页面跳转 跳转后可以后退
                // window.location.replace("url") 页面跳转 跳转后不可以后退
                // window.location.reload(true);
                window.location.replace("http://www.ekgc.cn")
            } else {
                span.innerHTML = prefix + count-- + suffix;
            }
        }, 1000);
        button.addEventListener('click', function(e) {
            clearInterval(timer);
            span.innerHTML = '<p>我不会离你而去的</p>'
        });
    });
</script>